package com.swak.frame.exception;

import com.swak.frame.dto.base.RestApiCode;

/**
 * 
 * ClassName: BaseException.java
 * 
 * @Description: Base Exception is the parent of all exceptions
 * @author colley.ma
 * @date 2021年3月15日
 */
public abstract class BaseException extends RuntimeException {
	private static final long serialVersionUID = 8097741380357729542L;
	private String errCode;
	private String errMessage;

	public BaseException(String errMessage) {
		super(errMessage);
		this.setErrMessage(errMessage);
	}

	public BaseException(String errCode, String errMessage) {
		super(errMessage);
		this.errCode = errCode;
		this.setErrMessage(errMessage);
	}

	public BaseException(String errMessage, Throwable e) {
		super(errMessage, e);
		this.setErrMessage(errMessage);
	}

	public BaseException(String errCode, String errMessage, Throwable e) {
		super(errMessage, e);
		this.errCode = errCode;
		this.setErrMessage(errMessage);
	}

	public String getErrCode() {
		return errCode;
	}

	public void setErrCode(String errCode) {
		this.errCode = errCode;
	}

	public String getErrMessage() {
		return errMessage;
	}

	public void setErrMessage(String errMessage) {
		this.errMessage = errMessage;
	}

	public void setErrCode(RestApiCode restApiCode) {
		this.errCode = restApiCode.getRetCode();
		this.errMessage = restApiCode.getRetMessage();
	}
}
